package design.mode.model.strategy.strategy.functiontype.function;

import design.mode.model.strategy.strategy.functiontype.function.renum.ReturnHomeStrategy;

/**
 * 函数式编程优化分发模式
 * @author ldanniel
 */
public class testM {
    public static void main(String[] args) {
        String string = returnHome("LOWER_RISK", 1);
        System.out.println(string);
    }
    public static String returnHome(String from,Integer id){
        for (ReturnHomeStrategy value : ReturnHomeStrategy.values()) {
            if(value.predicate().test(from)){
                return value.function().apply(id);
            }
        }
        throw new RuntimeException("执行失败");
    }
}
